More roughing in of auto-update. It's not very functional right now; server and...
authorrobertl <robertl>
Mon, 3 Aug 2009 05:16:23 +0000 (05:16 +0000)
committerrobertl <robertl>
Mon, 3 Aug 2009 05:16:23 +0000 (05:16 +0000)
gui/babeldata.h
gui/mainwindow.cpp
gui/upgrade.cpp
gui/upgrade.h

index dae04c2273ecee2bec59744a587e499e1b99001c..14db1dce845261af1ce9b489a07b4ab60dfdf7e0 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: babeldata.h,v 1.2 2009/07/31 18:32:32 robertl Exp $
+// $Id: babeldata.h,v 1.3 2009/08/03 05:16:23 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
@@ -25,6 +25,7 @@
 
 #include <QSettings>
 #include <QStringList>
+#include <QUuid>
 #include "setting.h"
 
 
@@ -54,7 +55,8 @@ public:
     outputBrowse(QString()),
     previewGmap(false),
     upgradeCheckMethod(0),
-    upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0)))
+    upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))),
+    installationUuid(QUuid::createUuid().toString())
   {
   };
   
@@ -96,6 +98,7 @@ public:
     sg.addVarSetting(new BoolSetting("app.previewGmap", previewGmap));
     sg.addVarSetting(new IntSetting("app.upgradeCheckMethod", upgradeCheckMethod));
     sg.addVarSetting(new DateTimeSetting("app.upgradeCheckTime", upgradeCheckTime));
+    sg.addVarSetting(new StringSetting("app.installationUuid", installationUuid));
   }
 
   static const int noType;
@@ -130,6 +133,7 @@ public:
   bool  previewGmap;
   int   upgradeCheckMethod;
   QDateTime upgradeCheckTime;
+  QString installationUuid;
 
 };
 
index 8913080aa5ffe3097a12ea5cba6bf461b2894ddf..ac766e59adcce95ae7b9b5883931eacfa4145620 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: mainwindow.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $
+// $Id: mainwindow.cpp,v 1.3 2009/08/03 05:16:23 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
@@ -188,7 +188,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
   //--- Restore from registry
   restoreSettings();
   upgrade = new UpgradeCheck();
-  upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, bd.upgradeCheckTime);
+  upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, bd.upgradeCheckTime, bd.installationUuid);
 }
 
 //------------------------------------------------------------------------
index 799cfe03d0510653474b273e5e075f4b94dd897a..b8efbdfbb018d8b4c0512c62d9c6d148f89353da 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: upgrade.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $
+// $Id: upgrade.cpp,v 1.3 2009/08/03 05:16:23 robertl Exp $
 /*
     Copyright (C) 2009  Robert Lipe, robertlipe@gpsbabel.org
 
 #include "upgrade.h"
 
 #include <QHttp>
+//#include <QHttpRequestHeader>
 #include <QMessageBox>
 #include <QDomDocument>
 
-//static const bool testing = true;
-static const bool testing = false;
+static const bool testing = true;
+// static const bool testing = false;
 
 static int versionAsNumber(const QString &s) 
 {
@@ -57,7 +58,8 @@ void UpgradeCheck::changeEvent(QEvent *)
 
 UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString &currentVersion,
                                                         int checkMethod,
-                                                        const QDateTime &lastCheckTime)
+                                                        const QDateTime &lastCheckTime,
+                                                        const QString &installationUuid)
 {
   this->currentVersion = currentVersion;
   this->upgradeCheckMethod = checkMethod;
@@ -74,9 +76,17 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString &currentV
   connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
           this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
   
+  QHttpRequestHeader header("POST", "/upgrade_check.html");
+       header.setValue("Host",  "www.gpsbabel.org");
+               header.setContentType("application/x-www-form-urlencoded");
+ QString args = "current_version=" + currentVersion;
+   args += "&installation=" + installationUuid;        header.setValue("Host", "www.gpsbabel.org");
+       
   http->setHost("www.gpsbabel.org");
-  httpRequestId = http->get("/updates.xml");
-  
+//     http->request(header);
+       http->request(header, args.toUtf8());
+//  httpRequestId = http->get("/upgrade_check.html");
+
   return UpgradeCheck::updateUnknown;
 }
 
index 6b7681b1e5c3bf2dc4837a8c115548bedaba60d1..914e305a7f72f90efa45d33dbf3b874fc465a3dd 100644 (file)
@@ -41,7 +41,8 @@ public:
 
   UpgradeCheck::updateStatus checkForUpgrade(const QString &babelVersion, 
                                             int upgradeCheckMethod,
-                                            const QDateTime &lastCheckTime);
+                                            const QDateTime &lastCheckTime,
+                                            const QString &installationUuid);
   QDateTime getUpgradeWarningTime() {
     return upgradeWarningTime;
   }